package com.uranus.common.VO;

import com.alibaba.fastjson.JSON;
import lombok.Data;

@Data
public class Result<T> {
    public Result() {
    }
    public Result(boolean success) {
        this.success = success;
    }
    private boolean success;
    private String message;
    private Object data;

    /**
     * buildSuccess
     */
    public static Result buildSuccess() {
        return buildSuccess("", null);
    }
    public static Result buildSuccess(String message) {
        return buildSuccess(message, null);
    }
    public static Result buildSuccess(Object data) {
        return buildSuccess(null, data);
    }
    public static Result buildSuccess(String message, Object data) {
        Result resultDO = new Result(true);
        resultDO.message = message;
        resultDO.data = data;
        return resultDO;
    }
    /**
     * buildError
     */
    public static Result buildError() {
        return buildError("", null);
    }
    public static Result buildError(String message) {
        return buildError(message, null);
    }
    public static Result buildError(Object data) {
        return buildError(null, data);
    }
    public static Result buildError(String message, Object data) {
        Result resultDO = new Result(false);
        resultDO.message = message;
        resultDO.data = data;
        return resultDO;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }






}
